package com.spark.prepareJob.tags
import com.spark.beans.Logs
import com.spark.prepareJob.constants.AdConstants

/**
  * 5）关键词（标签格式：Kxxx->1）xxx为关键字。关键词个数不能少于3个字符，
  * 且不能超过8个字符；关键字中如包含”|”,则分割成数组，转化成多个关键字标签
  * “麻辣小龙虾|麻辣香锅|与神对话|家”
  * 关键字：Keywords
  */
object KeywordTags extends Tags {
  override def extractTags(log: Logs): Map[String, Int] = {
    val keyword = log.keywords
    if(keyword == null){
      Map[String,Int]()
    }else{
      keyword.split("\\|").filter(word => word.length >=3 && word.length <=8).map(
        word => (AdConstants.AD_PREFIX_KEYWORD + word -> 1)
      ).toMap
    }
  }
}
